﻿<UserControl x:Class="Snippet2Vsi.UserControls.VsContentEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
             xmlns:Sample="clr-namespace:AvalonEdit.Sample;assembly=AvalonEdit.Sample"
             xmlns:ABC="clr-namespace:AttachedCommands.ACB;assembly=AttachedCommands" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="Navy"/>
        </Style>
        <Style  TargetType="{x:Type TextBox}">
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
            <Setter Property="AllowDrop" Value="true" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="Padding" Value="8,5,3,3" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Height" Value="Auto"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Grid HorizontalAlignment="Stretch">
                            <Border x:Name="BorderBase" Background="White" BorderThickness="1.4,1.4,1,1" 
                            BorderBrush="Silver" CornerRadius="10" />
                            <Label x:Name="TextPrompt" Content="{TemplateBinding Tag}" Visibility="Collapsed" Focusable="False"  Foreground="Silver" Margin="5,4,0,0" ></Label>
                            <ScrollViewer Margin="0" x:Name="PART_ContentHost" Foreground="{DynamicResource OutsideFontColor}" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsFocused" Value="False"></Condition>
                                    <Condition Property="Text" Value=""></Condition>
                                </MultiTrigger.Conditions>
                                <MultiTrigger.Setters>
                                    <Setter Property="Visibility" TargetName="TextPrompt" Value="Visible"></Setter>
                                </MultiTrigger.Setters>
                            </MultiTrigger>
                            <Trigger Property="IsFocused" Value="True">
                                <Setter Property="BorderThickness" TargetName="BorderBase" Value="2.4,2.4,1,1"></Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Foreground" Value="DimGray" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="Auto" MinHeight="35" />
        </Grid.RowDefinitions>
        <DockPanel LastChildFill="True" Grid.Row="0" Margin="4,3,0,3">
            <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">VsContent:</TextBlock>
            <Button Content="..." DockPanel.Dock="Right" VerticalAlignment="Center" Margin="0,0,4,0" Command="{Binding BrowseVsCommand}">
                <Button.ToolTip>
                    <Fluent:ScreenTip Title="VsContent Location"  Image="../Images\Browse.png"
                          Text="Location of  vsContent file to be converted." />
                </Button.ToolTip>
            </Button>
            <TextBox HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5,0,5,0" Background="#EAF3FB" Tag="Enter vscontent location" Text="{Binding VsPath}"></TextBox>
        </DockPanel>
        <Sample:XmlEditorViewer Grid.Row="1" x:Name="xmlEditor" ></Sample:XmlEditorViewer>
        <Button Grid.Row="3" HorizontalAlignment="Center" Width="100" Margin="5" Command="{Binding SaveCommand}" ABC:CommandBehavior.CommandParameter="{Binding ElementName=xmlEditor,Path=Html}">
            <Button.Content>
                <StackPanel Orientation="Horizontal">
                    <Image Source="../Images/save.png" Height="16" Width="16"/>
                    <TextBlock>Save</TextBlock>
                </StackPanel>
            </Button.Content>
            <Button.ToolTip>
                <Fluent:ScreenTip Title="Save"  Image="../Images\save.png"
                          Text="Save VsContent file." />
            </Button.ToolTip>
        </Button>
    </Grid>
</UserControl>
